package no.uia.ikt.gateway;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class Gateway2Frame extends JFrame implements Runnable, WindowListener {

    private final static String TITLE = "Gateway 2";
    private Gateway2 gateway;

    public Gateway2Frame() {
        super(TITLE);
        gateway = new Gateway2();
        getContentPane().setLayout(new BorderLayout());
        addWindowListener(this);
        pack();
        setVisible(true);
    }
    private Thread timerThread = null;

    public void run() {
        Thread thisThread = Thread.currentThread();

        while (timerThread == thisThread) {
//			getTvPanel().repaint();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
        }
    }

    public void start() {
        gateway.start();
        timerThread = new Thread(this);
        timerThread.start();
    }

    public void stop() {
        gateway.stop();
        timerThread = null;
    }

    public void windowActivated(WindowEvent e) {
    }

    public void windowClosed(WindowEvent e) {
    }

    public void windowClosing(WindowEvent e) {
        stop();
        System.exit(0);
    }

    public void windowDeactivated(WindowEvent e) {
    }

    public void windowDeiconified(WindowEvent e) {
    }

    public void windowIconified(WindowEvent e) {
    }

    public void windowOpened(WindowEvent e) {
    }

    public static void main(String args[]) {
        Gateway2Frame gateway = new Gateway2Frame();
        gateway.start();
    }
}

